package it.espsoft.easysuperenalotto.logic;

import it.espsoft.easysuperenalotto.R;

import java.util.ArrayList;

import android.widget.BaseAdapter;
import android.widget.GridView;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;

public class NumeriAdapter extends BaseAdapter {  
	private final int NUMBER_TEXT_COLOR = Color.WHITE;
	private Context mContext;  
    private ArrayList<String> estrazione = null;
    private String type;
    
    public NumeriAdapter(Context c, ArrayList<String> estrazione,String type) {  
	    mContext = c;  
	    this.type = type;
	    this.estrazione = estrazione;
    }  
    
    public View getView(int position, View convertView, ViewGroup parent) {
    	TextIcon numero;
    	
        if (convertView == null) {
        	numero = new TextIcon(mContext);
        	numero.setLayoutParams(new GridView.LayoutParams(36, 36));
        	numero.setScaleType(TextIcon.ScaleType.CENTER_INSIDE);
        	numero.setTextColor(NUMBER_TEXT_COLOR);
        } else {
        	numero = (TextIcon) convertView;
        }
        numero.setText(estrazione.get(position)); 
        
        if(position<=5){
        	numero.setImageResource(R.drawable.number_background);
        }else if(position==6){
        	
        	if(type.equals("GIOCATA"))
        		numero.setImageResource(R.drawable.superstar_background);
        	else
        		numero.setImageResource(R.drawable.jolly_background);
        	
        }else{
        	numero.setImageResource(R.drawable.superstar_background);
        }
        
        return numero;
    }

	public int getCount() {
		// TODO Auto-generated method stub
		return estrazione.size();
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}  
   }  
